package tij4.concurrent.exercise.ex03;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class P03Main01 {

    public static void CachedThreadPool(){
        ExecutorService executorService = Executors.newCachedThreadPool();
        for (int i = 0; i < 5; i++) {
            executorService.execute(new Practice01());
        }
        executorService.shutdown();
    }

    public static void FixedThreadPool(){
        ExecutorService executorService = Executors.newFixedThreadPool(5);
        for (int i = 0; i < 5; i++) {
            executorService.execute(new Practice01());
        }
        executorService.shutdown();
    }

    public static void SingleThreadPool(){
        ExecutorService executorService = Executors.newSingleThreadExecutor();
        for (int i = 0; i < 5; i++) {
            executorService.execute(new Practice01());
        }
        executorService.shutdown();
    }



    public static void main(String[] args) {
//        CachedThreadPool();
//        System.out.println("================================");
//        FixedThreadPool();
//        System.out.println("================================");
        SingleThreadPool();
    }
}
